package cn.stylefeng.guns.sys.config;

import org.apache.catalina.connector.Connector;
import org.apache.coyote.http11.Http11NioProtocol;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.stereotype.Component;

/**
 * Http支持类, 端口设置为443, 后续可只将http请求重定向为https请求, 对外只开放https请求方式
 *
 * @author zhushengjie
 * @date 2022-09-02
 */
//@Component
public class HttpSupportCustomer implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> {

    @Override
    public void customize(TomcatServletWebServerFactory factory) {
        Connector connector = new Connector(Http11NioProtocol.class.getName());
        connector.setScheme("http");
        connector.setPort(443);
        factory.addAdditionalTomcatConnectors(connector);
    }
}
